﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using DBUtility;//Please add references
namespace DataAccess
{
    /// <summary>
    /// 数据访问类:TB_HSYXRK_HD
    /// </summary>
    public partial class TB_HSYXRK_HD
    {
        public TB_HSYXRK_HD()
        { }
        #region  Method

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public static bool Exists(decimal NID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from TB_HSYXRK_HD");
            strSql.Append(" where NID=:NID ");
            OracleParameter[] parameters = {
					new OracleParameter(":NID", OracleType.Number,22)};
            parameters[0].Value = NID;

            return DbHelperOra.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static Model.TB_HSYXRK_HD Add(Model.TB_HSYXRK_HD model)
        {
            model.NID = CommonExecute.GetID(model.GetType().Name);
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into TB_HSYXRK_HD(");
            strSql.Append("NID,NSQID,CSN,NYPTS,NYPXH,CFQH,CSJW,SJLX,HSRQ,HSFBL,HSYXH,CJJ,FSJL,NSMPS,CHSBLC,SMFBL,CSMDW,CJTNR,NCFGH,NCFCH,NCFLH,NJZBH,C_BZ,YP_ZT,CREATE_SUER,CREATE_DATE)");
            strSql.Append(" values (");
            strSql.Append(":NID,:NSQID,:CSN,:NYPTS,:NYPXH,:CFQH,:CSJW,:SJLX,:HSRQ,:HSFBL,:HSYXH,:CJJ,:FSJL,:NSMPS,:CHSBLC,:SMFBL,:CSMDW,:CJTNR,:NCFGH,:NCFCH,:NCFLH,:NJZBH,:C_BZ,:YP_ZT,:CREATE_SUER,:CREATE_DATE)");
            OracleParameter[] parameters = {
					new OracleParameter(":NID", OracleType.Number,10),
					new OracleParameter(":NSQID", OracleType.Number,8),
					new OracleParameter(":CSN", OracleType.NVarChar),
					new OracleParameter(":NYPTS", OracleType.Number,1),
					new OracleParameter(":NYPXH", OracleType.NVarChar),
					new OracleParameter(":CFQH", OracleType.NVarChar),
					new OracleParameter(":CSJW", OracleType.NVarChar),
					new OracleParameter(":SJLX", OracleType.NVarChar),
					new OracleParameter(":HSRQ", OracleType.DateTime),
					new OracleParameter(":HSFBL", OracleType.NVarChar),
					new OracleParameter(":HSYXH", OracleType.NVarChar),
					new OracleParameter(":CJJ", OracleType.NVarChar),
					new OracleParameter(":FSJL", OracleType.Number,10),
					new OracleParameter(":NSMPS", OracleType.Number,10),
					new OracleParameter(":CHSBLC", OracleType.NVarChar),
					new OracleParameter(":SMFBL", OracleType.NVarChar),
					new OracleParameter(":CSMDW", OracleType.NVarChar),
					new OracleParameter(":CJTNR", OracleType.NVarChar),
					new OracleParameter(":NCFGH", OracleType.Number,10),
					new OracleParameter(":NCFCH", OracleType.Number,10),
					new OracleParameter(":NCFLH", OracleType.Number,10),
					new OracleParameter(":NJZBH", OracleType.NVarChar),
					new OracleParameter(":C_BZ", OracleType.NVarChar),
					new OracleParameter(":YP_ZT", OracleType.NVarChar),
					new OracleParameter(":CREATE_SUER", OracleType.NVarChar),
					new OracleParameter(":CREATE_DATE", OracleType.DateTime)};
            parameters[0].Value = model.NID;
            parameters[1].Value = model.NSQID;
            parameters[2].Value = model.CSN;
            parameters[3].Value = model.NYPTS;
            parameters[4].Value = model.NYPXH;
            parameters[5].Value = model.CFQH;
            parameters[6].Value = model.CSJW;
            parameters[7].Value = model.SJLX;
            parameters[8].Value = model.HSRQ;
            parameters[9].Value = model.HSFBL;
            parameters[10].Value = model.HSYXH;
            parameters[11].Value = model.CJJ;
            parameters[12].Value = model.FSJL;
            parameters[13].Value = model.NSMPS;
            parameters[14].Value = model.CHSBLC;
            parameters[15].Value = model.SMFBL;
            parameters[16].Value = model.CSMDW;
            parameters[17].Value = model.CJTNR;
            parameters[18].Value = model.NCFGH;
            parameters[19].Value = model.NCFCH;
            parameters[20].Value = model.NCFLH;
            parameters[21].Value = model.NJZBH;
            parameters[22].Value = model.C_BZ;
            parameters[23].Value = model.YP_ZT;
            parameters[24].Value = model.CREATE_SUER;
            parameters[25].Value = model.CREATE_DATE;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return model;
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(Model.TB_HSYXRK_HD model)
        {
            model.NID = CommonExecute.GetID(model.GetType().Name);
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update TB_HSYXRK_HD set ");
            strSql.Append("NSQID=:NSQID,");
            strSql.Append("CSN=:CSN,");
            strSql.Append("NYPTS=:NYPTS,");
            strSql.Append("NYPXH=:NYPXH,");
            strSql.Append("CFQH=:CFQH,");
            strSql.Append("CSJW=:CSJW,");
            strSql.Append("SJLX=:SJLX,");
            strSql.Append("HSRQ=:HSRQ,");
            strSql.Append("HSFBL=:HSFBL,");
            strSql.Append("HSYXH=:HSYXH,");
            strSql.Append("CJJ=:CJJ,");
            strSql.Append("FSJL=:FSJL,");
            strSql.Append("NSMPS=:NSMPS,");
            strSql.Append("CHSBLC=:CHSBLC,");
            strSql.Append("SMFBL=:SMFBL,");
            strSql.Append("CSMDW=:CSMDW,");
            strSql.Append("CJTNR=:CJTNR,");
            strSql.Append("NCFGH=:NCFGH,");
            strSql.Append("NCFCH=:NCFCH,");
            strSql.Append("NCFLH=:NCFLH,");
            strSql.Append("NJZBH=:NJZBH,");
            strSql.Append("C_BZ=:C_BZ,");
            strSql.Append("YP_ZT=:YP_ZT,");
            strSql.Append("CREATE_SUER=:CREATE_SUER,");
            strSql.Append("CREATE_DATE=:CREATE_DATE");
            strSql.Append(" where NID=:NID ");
            OracleParameter[] parameters = {
					new OracleParameter(":NSQID", OracleType.Number,8),
					new OracleParameter(":CSN", OracleType.NVarChar),
					new OracleParameter(":NYPTS", OracleType.Number,1),
					new OracleParameter(":NYPXH", OracleType.NVarChar),
					new OracleParameter(":CFQH", OracleType.NVarChar),
					new OracleParameter(":CSJW", OracleType.NVarChar),
					new OracleParameter(":SJLX", OracleType.NVarChar),
					new OracleParameter(":HSRQ", OracleType.DateTime),
					new OracleParameter(":HSFBL", OracleType.NVarChar),
					new OracleParameter(":HSYXH", OracleType.NVarChar),
					new OracleParameter(":CJJ", OracleType.NVarChar),
					new OracleParameter(":FSJL", OracleType.Number,10),
					new OracleParameter(":NSMPS", OracleType.Number,10),
					new OracleParameter(":CHSBLC", OracleType.NVarChar),
					new OracleParameter(":SMFBL", OracleType.NVarChar),
					new OracleParameter(":CSMDW", OracleType.NVarChar),
					new OracleParameter(":CJTNR", OracleType.NVarChar),
					new OracleParameter(":NCFGH", OracleType.Number,10),
					new OracleParameter(":NCFCH", OracleType.Number,10),
					new OracleParameter(":NCFLH", OracleType.Number,10),
					new OracleParameter(":NJZBH", OracleType.NVarChar),
					new OracleParameter(":C_BZ", OracleType.NVarChar),
					new OracleParameter(":YP_ZT", OracleType.NVarChar),
					new OracleParameter(":CREATE_SUER", OracleType.NVarChar),
					new OracleParameter(":CREATE_DATE", OracleType.DateTime),
					new OracleParameter(":NID", OracleType.Number,10)};
            parameters[0].Value = model.NSQID;
            parameters[1].Value = model.CSN;
            parameters[2].Value = model.NYPTS;
            parameters[3].Value = model.NYPXH;
            parameters[4].Value = model.CFQH;
            parameters[5].Value = model.CSJW;
            parameters[6].Value = model.SJLX;
            parameters[7].Value = model.HSRQ;
            parameters[8].Value = model.HSFBL;
            parameters[9].Value = model.HSYXH;
            parameters[10].Value = model.CJJ;
            parameters[11].Value = model.FSJL;
            parameters[12].Value = model.NSMPS;
            parameters[13].Value = model.CHSBLC;
            parameters[14].Value = model.SMFBL;
            parameters[15].Value = model.CSMDW;
            parameters[16].Value = model.CJTNR;
            parameters[17].Value = model.NCFGH;
            parameters[18].Value = model.NCFCH;
            parameters[19].Value = model.NCFLH;
            parameters[20].Value = model.NJZBH;
            parameters[21].Value = model.C_BZ;
            parameters[22].Value = model.YP_ZT;
            parameters[23].Value = model.CREATE_SUER;
            parameters[24].Value = model.CREATE_DATE;
            parameters[25].Value = model.NID;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public static bool Delete(decimal NID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from TB_HSYXRK_HD ");
            strSql.Append(" where NID=:NID ");
            OracleParameter[] parameters = {
					new OracleParameter(":NID", OracleType.Number,22)};
            parameters[0].Value = NID;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public static bool DeleteList(string where)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from TB_HSYXRK_HD ");
            if (!string.IsNullOrEmpty(where))
                strSql.Append(" where " + where + " ");
            int rows = DbHelperOra.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Model.TB_HSYXRK_HD GetModel(decimal NID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select NID,NSQID,CSN,NYPTS,NYPXH,CFQH,CSJW,SJLX,HSRQ,HSFBL,HSYXH,CJJ,FSJL,NSMPS,CHSBLC,SMFBL,CSMDW,CJTNR,NCFGH,NCFCH,NCFLH,NJZBH,C_BZ,YP_ZT,CREATE_SUER,CREATE_DATE from TB_HSYXRK_HD ");
            strSql.Append(" where NID=:NID ");
            OracleParameter[] parameters = {
					new OracleParameter(":NID", OracleType.Number,22)};
            parameters[0].Value = NID;

            Model.TB_HSYXRK_HD model = new Model.TB_HSYXRK_HD();
            DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["NID"] != null && ds.Tables[0].Rows[0]["NID"].ToString() != "")
                {
                    model.NID = decimal.Parse(ds.Tables[0].Rows[0]["NID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["NSQID"] != null && ds.Tables[0].Rows[0]["NSQID"].ToString() != "")
                {
                    model.NSQID = decimal.Parse(ds.Tables[0].Rows[0]["NSQID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CSN"] != null && ds.Tables[0].Rows[0]["CSN"].ToString() != "")
                {
                    model.CSN = ds.Tables[0].Rows[0]["CSN"].ToString();
                }
                if (ds.Tables[0].Rows[0]["NYPTS"] != null && ds.Tables[0].Rows[0]["NYPTS"].ToString() != "")
                {
                    model.NYPTS = decimal.Parse(ds.Tables[0].Rows[0]["NYPTS"].ToString());
                }
                if (ds.Tables[0].Rows[0]["NYPXH"] != null && ds.Tables[0].Rows[0]["NYPXH"].ToString() != "")
                {
                    model.NYPXH = ds.Tables[0].Rows[0]["NYPXH"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CFQH"] != null && ds.Tables[0].Rows[0]["CFQH"].ToString() != "")
                {
                    model.CFQH = ds.Tables[0].Rows[0]["CFQH"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CSJW"] != null && ds.Tables[0].Rows[0]["CSJW"].ToString() != "")
                {
                    model.CSJW = ds.Tables[0].Rows[0]["CSJW"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SJLX"] != null && ds.Tables[0].Rows[0]["SJLX"].ToString() != "")
                {
                    model.SJLX = ds.Tables[0].Rows[0]["SJLX"].ToString();
                }
                if (ds.Tables[0].Rows[0]["HSRQ"] != null && ds.Tables[0].Rows[0]["HSRQ"].ToString() != "")
                {
                    model.HSRQ = DateTime.Parse(ds.Tables[0].Rows[0]["HSRQ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["HSFBL"] != null && ds.Tables[0].Rows[0]["HSFBL"].ToString() != "")
                {
                    model.HSFBL = ds.Tables[0].Rows[0]["HSFBL"].ToString();
                }
                if (ds.Tables[0].Rows[0]["HSYXH"] != null && ds.Tables[0].Rows[0]["HSYXH"].ToString() != "")
                {
                    model.HSYXH = ds.Tables[0].Rows[0]["HSYXH"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CJJ"] != null && ds.Tables[0].Rows[0]["CJJ"].ToString() != "")
                {
                    model.CJJ = ds.Tables[0].Rows[0]["CJJ"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FSJL"] != null && ds.Tables[0].Rows[0]["FSJL"].ToString() != "")
                {
                    model.FSJL = decimal.Parse(ds.Tables[0].Rows[0]["FSJL"].ToString());
                }
                if (ds.Tables[0].Rows[0]["NSMPS"] != null && ds.Tables[0].Rows[0]["NSMPS"].ToString() != "")
                {
                    model.NSMPS = decimal.Parse(ds.Tables[0].Rows[0]["NSMPS"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CHSBLC"] != null && ds.Tables[0].Rows[0]["CHSBLC"].ToString() != "")
                {
                    model.CHSBLC = ds.Tables[0].Rows[0]["CHSBLC"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SMFBL"] != null && ds.Tables[0].Rows[0]["SMFBL"].ToString() != "")
                {
                    model.SMFBL = ds.Tables[0].Rows[0]["SMFBL"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CSMDW"] != null && ds.Tables[0].Rows[0]["CSMDW"].ToString() != "")
                {
                    model.CSMDW = ds.Tables[0].Rows[0]["CSMDW"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CJTNR"] != null && ds.Tables[0].Rows[0]["CJTNR"].ToString() != "")
                {
                    model.CJTNR = ds.Tables[0].Rows[0]["CJTNR"].ToString();
                }
                if (ds.Tables[0].Rows[0]["NCFGH"] != null && ds.Tables[0].Rows[0]["NCFGH"].ToString() != "")
                {
                    model.NCFGH = decimal.Parse(ds.Tables[0].Rows[0]["NCFGH"].ToString());
                }
                if (ds.Tables[0].Rows[0]["NCFCH"] != null && ds.Tables[0].Rows[0]["NCFCH"].ToString() != "")
                {
                    model.NCFCH = decimal.Parse(ds.Tables[0].Rows[0]["NCFCH"].ToString());
                }
                if (ds.Tables[0].Rows[0]["NCFLH"] != null && ds.Tables[0].Rows[0]["NCFLH"].ToString() != "")
                {
                    model.NCFLH = decimal.Parse(ds.Tables[0].Rows[0]["NCFLH"].ToString());
                }
                if (ds.Tables[0].Rows[0]["NJZBH"] != null && ds.Tables[0].Rows[0]["NJZBH"].ToString() != "")
                {
                    model.NJZBH = ds.Tables[0].Rows[0]["NJZBH"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_BZ"] != null && ds.Tables[0].Rows[0]["C_BZ"].ToString() != "")
                {
                    model.C_BZ = ds.Tables[0].Rows[0]["C_BZ"].ToString();
                }
                if (ds.Tables[0].Rows[0]["YP_ZT"] != null && ds.Tables[0].Rows[0]["YP_ZT"].ToString() != "")
                {
                    model.YP_ZT = ds.Tables[0].Rows[0]["YP_ZT"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CREATE_SUER"] != null && ds.Tables[0].Rows[0]["CREATE_SUER"].ToString() != "")
                {
                    model.CREATE_SUER = ds.Tables[0].Rows[0]["CREATE_SUER"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CREATE_DATE"] != null && ds.Tables[0].Rows[0]["CREATE_DATE"].ToString() != "")
                {
                    model.CREATE_DATE = DateTime.Parse(ds.Tables[0].Rows[0]["CREATE_DATE"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select NID,NSQID,CSN,NYPTS,NYPXH,CFQH,CSJW,SJLX,HSRQ,HSFBL,HSYXH,CJJ,FSJL,NSMPS,CHSBLC,SMFBL,CSMDW,CJTNR,NCFGH,NCFCH,NCFLH,NJZBH,C_BZ,YP_ZT,CREATE_SUER,CREATE_DATE ");
            strSql.Append(" FROM TB_HSYXRK_HD ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperOra.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetListFromView(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM V_HSYXRK_BASE_HD ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperOra.Query(strSql.ToString());
        }

        /*
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            OracleParameter[] parameters = {
                    new OracleParameter(":tblName", OracleType.VarChar, 255),
                    new OracleParameter(":fldName", OracleType.VarChar, 255),
                    new OracleParameter(":PageSize", OracleType.Number),
                    new OracleParameter(":PageIndex", OracleType.Number),
                    new OracleParameter(":IsReCount", OracleType.Clob),
                    new OracleParameter(":OrderType", OracleType.Clob),
                    new OracleParameter(":strWhere", OracleType.VarChar,1000),
                    };
            parameters[0].Value = "TB_HSYXRK_HD";
            parameters[1].Value = "NID";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;	
            return DbHelperOra.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        }*/

        #endregion  Method
    }
}

